package com.cloud.utils;

import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletResponse;

/**
 * cookie 工具类
 *
 * @author yzj
 */
public class CookieUtils {

    /**
     * 设置Cookie信息
     *
     * @param domain
     * @param name   参数key
     * @param value  参数值
     */
    public static void setCookie(String domain, String name, String value) {
        HttpServletResponse response = ServletUtils.getResponse();
        Cookie cookie = new Cookie(name, value);
        // 设置存活时间6小时
        cookie.setMaxAge(3600 * 6);
        cookie.setDomain(domain);
        cookie.setPath("/");
        response.addCookie(cookie);
    }

}
